package com.heima.media.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.MediaApp;
import com.heima.media.entity.WmChannel;
import com.heima.media.service.IWmChannelService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = MediaApp.class)
public class WmChannelServiceImplTest {
    @Autowired
    private IWmChannelService channelService;


    @Test
    public void test(){
        //WmChannel channel = channelService.getById(1L);
        //System.out.println(channel);

        //List<WmChannel> list = channelService.list();
        //System.out.println(list);


        //根据频道名称模糊查询
        //QueryWrapper<WmChannel> queryWrapper = new QueryWrapper<>();
        //queryWrapper.like("name", "java");
        //queryWrapper.eq("is_default", true);
        //List<WmChannel> list = channelService.list(queryWrapper);


        LambdaQueryWrapper<WmChannel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(WmChannel::getName, "java");
        queryWrapper.eq(WmChannel::getIsDefault, true);
        List<WmChannel> list = channelService.list(queryWrapper);


        System.out.println(list);
    }
}
